#include "TextureLoader.h"

#define STB_IMAGE_STATIC
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image.h"
#include "stb_image_write.h"

namespace SL
{
unsigned char* TextureLoader::loadTexture(const char* filepath, int* width, int* height, int* channels, int desired_channels)
{
    return stbi_load(filepath, width, height, channels, 4);
}

float* TextureLoader::loadHDR(const char* filepath, int* width, int* height, int* channels)
{
    return stbi_loadf(filepath, width, height, channels, 0);
}
void TextureLoader::storeHDR(char const* filename, int w, int h, int comp, const float* data)
{
    stbi_write_hdr(filename, w, h, comp, data);
}
void TextureLoader::freeTexture(unsigned char* ptr)
{
    STBI_FREE(ptr);
}

} // namespace SL